package com.fenxiangle.yueding.feature.mine.view;


import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.fenxiangle.yueding.R;
import com.fenxiangle.yueding.feature.mine.view.adapter.CouponAdpter;
import com.fenxiangle.yueding.framework.DataServer;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.suozhang.framework.framework.BaseFragment;
import com.suozhang.framework.widget.EmptyView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * A simple {@link Fragment} subclass.
 */
public class CouponFragment extends BaseFragment implements BaseQuickAdapter.OnItemClickListener, BaseQuickAdapter.OnItemChildClickListener, OnRefreshListener, BaseQuickAdapter.RequestLoadMoreListener {
    @BindView(R.id.rv_coupon)
    RecyclerView mRvCoupon;
    Unbinder unbinder;
    @BindView(R.id.smartRefesh)
    SmartRefreshLayout mSmartRefesh;
    Unbinder unbinder1;
    private int mType = 0;
    private CouponAdpter mAdapter;
    private EmptyView mEmptyView;

    public static CouponFragment getInstance(int mType) {
        CouponFragment sf = new CouponFragment();
        sf.mType = mType;
        return sf;
    }


    @Override
    public int attachLayoutRes() {
        return R.layout.fragment_coupon;
    }

    @Override
    protected void initInjector() {

    }

    @Override
    protected void initView() {

    }

    @Override
    protected void initData() {
        initAdapter(mType);
    }

    @Override
    protected void initEvent() {

    }

    private void initAdapter(int type) {
        mAdapter = new CouponAdpter(type);
        mEmptyView = new EmptyView(mRvCoupon);
        mRvCoupon.setLayoutManager(new LinearLayoutManager(getActivity()));
        mAdapter.bindToRecyclerView(mRvCoupon);
        mAdapter.setOnItemClickListener(this);
        mAdapter.setOnItemChildClickListener(this);
        mSmartRefesh.setEnableLoadMore(false);
        mSmartRefesh.setOnRefreshListener(this);
        mAdapter.setOnLoadMoreListener(this);
        mAdapter.setNewData(null);

    }


    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {

    }

    @Override
    public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
        getActivity().finish();
    }

    @Override
    public void onRefresh(@NonNull RefreshLayout refreshLayout) {

    }

    @Override
    public void onLoadMoreRequested() {

    }
}
